<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- 标题 -->
    <title>修行日记</title>
    <!-- 关键词 -->
    <meta name="keywords" content="" />
    <!-- 网站简介 -->
    <meta name="description" content="" />
    <!-- 自适应屏幕 -->
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <!-- IE兼容 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="css/banner.css" rel="stylesheet" />
    <!-- 最新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="css/bootstrap.css">
    <!-- 核心 CSS 文件 -->
    <link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body >
    <!-- 顶部 -->
    <div class="top raise-usercenter faq-top">
        <a href="" class="userce">发布</a>
        修行日记
        <a href="" class="goback"><span class="iconfont">&#xe60e;</span></a>
    </div>

    <div class="notes-top">
        <form action="">
            <div class="notes-title">
                <input type="text" placeholder="请输入标题">
            </div>  
            <div class="notes-content">
                <textarea name="" id="" placeholder="正文"></textarea>
            </div>
            <div class="notes-photos clearfix">
                <div class="left">
                    <div class="note-input-file">
                        <input type="file" name="file" id="file" value="" accept="image/*" multiple onchange="imgChange('note-input-photo','note-input-file');" />
                    </div>
                </div>
                <div class="right">0/1000</div>
            </div>
        
            <ul class="notes-sort clearfix">
                <li><a href="javascript:;">善行</a></li>
                <li><a href="javascript:;">忏悔</a></li>
                <li><a href="javascript:;">感悟</a></li>
                <li><a href="javascript:;">其他</a></li>
            </ul>
            <div class="notes-privacy">
                <input type="checkbox"> 不公开  
            </div>
            <div class="notes-rlues">
                <input type="checkbox"><a href=""> 遵守社区守则，文明提问 </a>
            </div> 
        </form>
    </div>

    <!--遮罩层-->
    <div class="note-input-mask">
        <!--弹出框-->
        <div class="note-input-alert">
            <p>确定要删除这张图片吗？</p>
            <p>
                <span class="note-input-cancel">取消</span>
                <span class="note-input-sure">确定</span>
            </p>
        </div>
    </div>

    
    <!-- 上传的图片 -->
    <div class="note-input-photo clearfix dn">
        
    </div>

    <!-- jQuery文件 -->
    <script src="js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="js/bootstrap.min.js"></script>
    <script>
        $(".notes-sort li").click(function(){
            $(".active").removeClass("active");
            $(this).addClass("active");
        })
        $(".note-input-file").click(function(){
            $(".note-input-photo").removeClass("dn");
        })
    </script>

    <!-- 上传图片 -->
    <script type="text/javascript">
        (function(doc, win) {
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function() {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    if (clientWidth >= 640) {
                        docEl.style.fontSize = '100px';
                    } else {
                        docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
                    }
                };

            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);

        function imgChange(obj1, obj2) {
            //获取点击的文本框
            var file = document.getElementById("file");
            //存放图片的父级元素
            var imgContainer = document.getElementsByClassName(obj1)[0];
            //获取的图片文件
            var fileList = file.files;
            //文本框的父级元素
            var input = document.getElementsByClassName(obj2)[0];
            var imgArr = [];
            //遍历获取到得图片文件
            for (var i = 0; i < fileList.length; i++) {
                var imgUrl = window.URL.createObjectURL(file.files[i]);
                imgArr.push(imgUrl);
                var img = document.createElement("img");
                img.setAttribute("src", imgArr[i]);
                var imgAdd = document.createElement("div");
                imgAdd.setAttribute("class", "note-input-addImg");
    
                imgAdd.appendChild(img);
                imgContainer.appendChild(imgAdd);
            };
            imgRemove();
        };

        function imgRemove() {
            var imgList = document.getElementsByClassName("note-input-addImg");
            var mask = document.getElementsByClassName("note-input-mask")[0];
            var cancel = document.getElementsByClassName("note-input-cancel")[0];
            var sure = document.getElementsByClassName("note-input-sure")[0];
            for (var j = 0; j < imgList.length; j++) {
                imgList[j].index = j;
                imgList[j].onclick = function() {
                    var t = this;
                    mask.style.display = "block";
                    cancel.onclick = function() {
                        mask.style.display = "none";
                    };
                    sure.onclick = function() {
                        mask.style.display = "none";
                        t.style.display = "none";
                    };

                }
            };
        };

    </script>
</body>
</html>
